import type { Application } from "express"
import routes from "./routes"
//导入oracle对象
import oracle from "../oracle"
//导入相关自定义函数
import { callbackFn } from "../utils"
import type { Router } from "express"
import express from "express"

//循环注册路由
export default (app: Application) => {
  for (let route of routes) {
    //注册路由格式
    //app.use(url,router)
    //每次注册都要抓取新的router,防止重复挂载
    const router:Router = express.Router()
    app.use(route.url, route.fn(router, oracle, callbackFn))
  }
}
